﻿using System;
using System.Text;
using IAM.Interface.Common.Encrypt;
using System.Web;
using IAM.Interface.Model.ENUM;

namespace IAM.Interface.Common.Providers
{
    /// <summary>
    /// xml传送接口
    /// </summary>
    public abstract class IProvider
    {
        #region 属性
        protected string _url= "";
        protected string _sendstring = "";
        protected string _xml = "";
        protected string _sign = "";
        protected EncryptDecrypt _endecrypt = null;
        /// <summary>
        /// 目的地址
        /// </summary>
        public virtual string URL
        {
            set
            {
                _url = value;
            }
            get
            {
                return _url;
            }
        }
        /// <summary>
        /// 发送的信息
        /// </summary>
        public virtual string SendStr
        {
            get
            {
                return _sendstring;
            }
        }
        /// <summary>
        /// 主体信息包
        /// </summary>
        public virtual string XML
        {
            get
            {
                return _xml;
            }
            set
            {
                _xml = value;
            }
        }
        public virtual EncryptDecrypt EncryptDecrypt
        {
            get
            {
                return _endecrypt;
            }
        }
        /// <summary>
        /// 主体信息的签名
        /// </summary>
        public virtual string Sign
        {
            get
            {
                return _sign;
            }
            set
            {
                _sign = value;
            }
        }
        #endregion
        #region 依据发出的请求返回响应的xml字符串
        /// <summary>
        /// 依据发出的请求返回响应的xml字符串
        /// </summary>
        /// <returns></returns>
        public virtual string GetResponseStr()
        {
            return "";
        }
        #endregion
        #region 拼写完整的发送字符串
        /// <summary>
        /// 拼写完整的发送字符串
        /// </summary>
        /// <returns></returns>
        protected virtual void SetWholeSendStr()
        {
          // int intEncryptEnum = (int)EncryptDecrypt.EncryptType;

            string wholexml = "xml=" + IAM.Interface.Common.EnDeCoding.Encode(XML);
            wholexml = wholexml + "&sign=" + IAM.Interface.Common.EnDeCoding.Encode(Sign);
            _sendstring = wholexml;
        }
        #endregion
    }
}
